import { FormSchema } from '/@/components/Table';
import { userStore } from '/@/store/modules/user';
import { GetcitylistApi } from '/@/api/activityAdmin/index';
export const accountFormSchema: FormSchema[] = [
  {
    label: 'userId',
    field: 'userId',
    component: 'Input',
    show: false,
  },
  {
    field: 'nickName',
    label: '用户姓名：',
    component: 'Input',
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入用户姓名',
      },
    ],
  },
  {
    field: 'phonenumber',
    label: '联系方式：',
    component: 'Input',
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入联系方式',
      },
    ],
  },
  {
    field: 'userName',
    label: '登录账号：',
    component: 'Input',
    required: true,
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入登录账号',
      },
    ],
  },
  {
    field: 'password',
    label: '账号密码：',
    component: 'InputPassword',
    // rules: [
    //   {
    //     required: true,
    //     message: '请输入账号密码',
    //   },
    // ],
    colProps: { span: 22 },
    // dynamicRules: ({ values }) => {
    //   return values.userId ? [] : [{ required: true, message: '请输入账号密码' }];
    // },
  },
  {
    label: '角色：',
    field: 'roleIds',
    component: 'RoleSelect',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      return values.roleIds == 1;
    },
  },
  {
    label: '区域：',
    field: 'operatorId',
    component: 'ApiSelect',
    componentProps: {
      api: GetcitylistApi,
      numberToString: true,
      resultField: 'data',
      labelField: 'city',
      valueField: 'id',
    },
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      return !userStore.getUserInfoByIdState.admin || values.roleIds == 1;
    },
  },
  {
    field: 'status',
    label: '状态：',
    component: 'RadioButtonGroup',
    defaultValue: '0',
    componentProps: {
      options: [
        { label: '启用', value: '0' },
        { label: '停用', value: '1' },
      ],
    },
    colProps: { span: 22 },
  },
  {
    label: '备注：',
    field: 'remark',
    component: 'InputTextArea',
    colProps: { span: 22 },
  },
];
export const addAccountFormSchema: FormSchema[] = [
  {
    label: 'userId',
    field: 'userId',
    component: 'Input',
    show: false,
  },
  {
    field: 'nickName',
    label: '用户姓名：',
    component: 'Input',
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入用户姓名',
      },
    ],
  },
  {
    field: 'phonenumber',
    label: '联系方式：',
    component: 'Input',
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入联系方式',
      },
    ],
  },
  {
    field: 'userName',
    label: '登录账号：',
    component: 'Input',
    required: true,
    colProps: { span: 22 },
    rules: [
      {
        required: true,
        message: '请输入登录账号',
      },
    ],
  },
  {
    field: 'password',
    label: '账号密码：',
    component: 'InputPassword',
    rules: [
      {
        required: true,
        message: '请输入账号密码',
      },
    ],
    colProps: { span: 22 },
    // dynamicRules: ({ values }) => {
    //   return values.userId ? [] : [{ required: true, message: '请输入账号密码' }];
    // },
  },
  {
    label: '角色：',
    field: 'roleIds',
    component: 'RoleSelect',
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      return values.roleIds == 1;
    },
  },
  {
    label: '区域：',
    field: 'operatorId',
    component: 'ApiSelect',
    componentProps: {
      api: GetcitylistApi,
      numberToString: true,
      resultField: 'data',
      labelField: 'city',
      valueField: 'id',
    },
    colProps: { span: 22 },
    dynamicDisabled: ({ values }) => {
      return !userStore.getUserInfoByIdState.admin || values.roleIds == 1;
    },
  },
  {
    field: 'status',
    label: '状态：',
    component: 'RadioButtonGroup',
    defaultValue: '0',
    componentProps: {
      options: [
        { label: '启用', value: '0' },
        { label: '停用', value: '1' },
      ],
    },
    colProps: { span: 22 },
  },
  {
    label: '备注：',
    field: 'remark',
    component: 'InputTextArea',
    colProps: { span: 22 },
  },
];
